﻿Imports System.Windows.Forms
<Serializable()> Public Class CPlineToolV2
    Inherits BaseTool



    '这里使用的是和polyshape相同的图形，只是不记录最后一个点而已


    Public Overrides Sub mouseDown(ByVal sender As Object, ByVal e As AxMapWinGIS._DMapEvents_MouseDownEvent)

        If e.button = 1 Then

            If Me.OperShapeProperty Is Nothing Then '第一次绘制



                Me.OperShapeProperty = ShapeFactory.getNewPolyShape()


                Me.OperShapeProperty.P1Property = Me.DownPointProperty
                Me.OperShapeProperty.plist.Add(Me.DownPointProperty)



            Else

                '对于直线来讲，这里的绘制已经结束
                Dim n As Integer = Me.OperShapeProperty.plist.Count
                If n = 1 Then

                    Me.getScreen(Me.DownPointProperty)

                    ControlPaint.DrawReversibleLine(getScreen(Me.OperShapeProperty.plist.Item(n - 1)), getScreen(Me.DownPointProperty), lColor)
                    ControlPaint.DrawReversibleLine(getScreen(Me.OperShapeProperty.plist.Item(n - 1)), getScreen(Me.DownPointProperty), lColor)

                    '  refForm.ControlPaint.

                End If


                Me.OperShapeProperty.plist.Add(Me.DownPointProperty)






            End If

        ElseIf e.button = 2 Then

            'InvokeEndDrawing()
            'Me.OperShapeProperty = Nothing

        End If
    End Sub

    Public Overrides Sub mouseDrag(ByVal sender As Object, ByVal e As AxMapWinGIS._DMapEvents_MouseMoveEvent)

    End Sub

    Public Overrides Sub mouseMove(ByVal sender As Object, ByVal e As AxMapWinGIS._DMapEvents_MouseMoveEvent)
        If Me.OperShapeProperty.plist.Count = 1 Then
            '绘制固定线部分



            ControlPaint.DrawReversibleLine(getScreen(Me.OperShapeProperty.plist.Item(0)), getScreen(Me.OldmovepointProperty), lColor)

            ControlPaint.DrawReversibleLine(getScreen(Me.OperShapeProperty.plist.Item(0)), getScreen(Me.NewmovepointProperty), lColor)




        End If

        If Me.OperShapeProperty.plist.Count > 1 Then
            Dim n As Integer = Me.OperShapeProperty.plist.Count

            ' ControlPaint.DrawReversibleLine(getScreen(Me.OperShapeProperty.plist.Item(0)), getScreen(Me.OldmovepointProperty), lColor)

            'ControlPaint.DrawReversibleLine(getScreen(Me.OperShapeProperty.plist.Item(0)), getScreen(Me.NewmovepointProperty), lColor)

            ControlPaint.DrawReversibleLine(getScreen(Me.OperShapeProperty.plist.Item(n - 1)), getScreen(Me.OldmovepointProperty), lColor)

            ControlPaint.DrawReversibleLine(getScreen(Me.OperShapeProperty.plist.Item(n - 1)), getScreen(Me.NewmovepointProperty), lColor)


        End If
    End Sub

    Public Overrides Sub mouseUp(ByVal sender As Object, ByVal e As AxMapWinGIS._DMapEvents_MouseUpEvent)

    End Sub


    Public Overrides Sub mouseDblClick(ByVal sender As Object, ByVal e As System.EventArgs)
        If Me.OperShapeProperty.plist.Count > 1 Then

            InvokeEndDrawing()
            Me.OperShapeProperty = Nothing

        Else
            Me.CancelDraw()
            mapwin.Redraw()

        End If
       

    End Sub


    Public Overrides Sub setself()

    End Sub

    Public Overrides Sub unSet()

    End Sub
End Class

